package org.hxzon.demo.scala.traitdemo

class Human(val name: String) extends Friend
class Man(override val name: String) extends Human(name)
class Woman(override val name: String) extends Human(name)

class Animal
class Cat(val name: String) extends Animal
class Dog(val name: String) extends Animal with Friend {
  override def listen = printf("%s listening quietly\n", name)
}

object FriendDemo {
  def main(args: Array[String]): Unit = {
    val john = new Man("John")
    val sara = new Woman("Sara")
    val comet = new Dog("Comet")

    john.listen
    sara.listen
    comet.listen

    val snowy = new Cat("Snowy") with Friend
    snowy.listen()
    val kity = new Cat("Kity")
    //kity.listen//compiler error
  }
}
